#!/bin/bash

host='localhost'
user='root'
password='123456'
db=$1
table=$2

lines=$(mysql -h${host} -u${user} -p${password} -e "SELECT COUNT(*) FROM ${db}.${table};" 2> /dev/null | tail -1)

[ "${lines}" == '' ] && exit

if [[ "${lines}" =~ 0$ ]];then
        counts=$[lines/10-1]
else
        counts=$[lines/10]
fi

for i in `seq 0 ${counts}`
do
		sleep 1
        echo -e "正在获取第\e[31m$[i+1]\e[0m/\e[32m$[counts+1]\e[0m页"
        item=$[i*10]
        mysql -h${host} -u${user} -p${password} -e "SELECT * FROM ${db}.${table} LIMIT ${item},10;" 2> /dev/null
done
